package com.tsai.wuxi.traffic.ui;

import java.util.List;

import com.tsai.wuxi.traffic.R;
import com.tsai.wuxi.traffic.R.id;
import com.tsai.wuxi.traffic.R.layout;
import com.tsai.wuxi.traffic.model.Ticket;
import com.tsai.wuxi.traffic.util.HttpUtils;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class TicketSearchResultActivity extends Activity{
	
	private TextView toValue;
	private ListView listView;  
	private List<Ticket> list;
	private TicketAdapter ticketAdapter;
	
	private String to;
	private String date;
	
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.ticket_search_result);  
        
        this.toValue = (TextView)findViewById(R.id.to_value);
        this.to = (String)getIntent().getExtras().get("to");
        this.date = (String)getIntent().getExtras().get("date");
        toValue.setText(to);
        
        list = HttpUtils.getTickets(date, to);
        
        if(list!=null){
	        listView = (ListView)this.findViewById(R.id.listview);  
	        ticketAdapter = new TicketAdapter(this,list);
	        listView.setAdapter(ticketAdapter);
        }else{
        	//show error msg
        }
        
    }  
}
